package com.example.easy.excel.demo.servcie.impl;

import com.example.easy.excel.demo.servcie.DataService;
import com.example.easy.excel.demo.utils.ExcelUtils;
import com.example.easy.excel.demo.utils.ParamUtils;
import com.example.easy.excel.demo.data.*;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Service
@AllArgsConstructor
@Slf4j
public class DataServiceImpl implements DataService {


    @Override
    public void example(HttpServletResponse response) {
        List<DemoData> data = ParamUtils.getDemoData();
        ExcelUtils.createResponse(response,"模板");
        ExcelUtils.writeData(response,"模板",data,DemoData.class);
    }

    @Override
    public void demoData(HttpServletResponse response) {
        List<DemoData> data = ParamUtils.getDemoData();
        ExcelUtils.createResponse(response,"模板");
        ExcelUtils.writeData(response,"模板",data,DemoData.class);
    }

    @Override
    public void complexHeadData(HttpServletResponse response) {
        List<ComplexHeadData> data = ParamUtils.getComplexHeadData();
        ExcelUtils.createResponse(response,"模板");
        ExcelUtils.writeData(response,"模板",data,ComplexHeadData.class);
    }

    @Override
    public void converterData(HttpServletResponse response) {
        List<ConverterData> data = ParamUtils.getConverterData();
        ExcelUtils.createResponse(response,"模板");
        ExcelUtils.writeData(response,"模板",data, ConverterData.class);
    }

    @Override
    public void writeCellDemoData(HttpServletResponse response) {
        List<WriteCellDemoData> data = ParamUtils.getWriteCellDemoData();
        ExcelUtils.createResponse(response,"模板");
        ExcelUtils.writeData(response,"模板",data, WriteCellDemoData.class);
    }

    //WidthAndHeightData
    @Override
    public void widthAndHeightData(HttpServletResponse response) {
        List<WidthAndHeightData> data = ParamUtils.getWidthAndHeightData();
        ExcelUtils.createResponse(response,"模板");
        ExcelUtils.writeData(response,"模板",data, WidthAndHeightData.class);
    }

    //DemoStyleData
    @Override
    public void demoStyleData(HttpServletResponse response) {
        List<DemoStyleData> data = ParamUtils.getDemoStyleData();
        ExcelUtils.createResponse(response,"模板");
        ExcelUtils.writeData(response,"模板",data, DemoStyleData.class);
    }
}
